package com.tqhh.meimei.service.impl;

import com.tqhh.meimei.config.MmConfig;
import com.tqhh.meimei.mapper.ContentsMapper;
import com.tqhh.meimei.model.Contents;
import com.tqhh.meimei.service.ContentsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Stream;


@Service
public class ContentsServiceImpl implements ContentsService {
    @Autowired
    ContentsMapper contentsMapper;
    @Autowired
    MmConfig mmConfig;

    @Override
    public List<Contents> getArchives(List<Long> cids) {
        List<Contents> results = contentsMapper.getArchives(cids);
        results.stream().forEach(contents -> {
            contents.setDomain(mmConfig.getDomain());
            contents.setShareUrl(String.format("%s/archives/%s", mmConfig.getDomain(), contents.getCid()));
        });
        return results;
    }
}
